//
//  AWCmdMessage.m
//  AtWork2
//
//  Created by lucas on 15/4/29.
//  Copyright (c) 2015年 Foreveross. All rights reserved.
//

#import "AWCmdMessage.h"

@interface AWCmdMessage ()

@property (nonatomic, copy, readwrite) NSString *type;

@property (nonatomic, assign, readwrite) AWCmdMessageOperation cmdMessageOperation;

@end

static inline AWCmdMessageOperation parseCmdMessageOperation(NSString *operation) {
    if ([operation.uppercaseString isEqualToString:AWMessageKOperationKick]) {
        return AWCmdMessageOperationKick;
    }
    if ([operation.uppercaseString isEqualToString:AWMessageKOperationResetCredentials]) {
        return AWCmdMessageOperationResetCredentials;
    }
    if ([operation.uppercaseString isEqualToString:AWMessageKOperationRemoved]) {
        return AWCmdMessageOperationUserRemoved;
    }
    return NSNotFound;
}

@implementation AWCmdMessage

- (NSString *)type {
    return [self bodyValueForKey:AWMessageKType];
}

- (AWCmdMessageOperation)cmdMessageOperation {
    return parseCmdMessageOperation([self bodyValueForKey:AWMessageKOperation]);
}

@end
